package nevo.test;

import java.util.*;

import nevo.core.*;
import nevo.pkgs.es.*;

public class EvolutionaryOptimizerTest1 extends OptimizerTest1
{
	protected Optimizer setup()
	{
		EvolutionaryOptimizer ev = new EvolutionaryOptimizer();
		
		DeltaMutator dmut = new DeltaMutator();
		dmut.setMaxdelta(.01);
		dmut.setMindelta(-.01);
		ev.setMutator(dmut);
		
		ev.setNumReproducingParents(10);
		ev.setNumOffspring(1);
		ev.setParentSelector(new UniformSelector());
		ev.setPopulationSelector(new ElitistSelector());
		
		return ev;
	}
	
	protected int getMaxIterations() { return 200; }
	protected double getExpectedResidual() { return 1e-3; }	
		
	protected List<Map<String,Object>> getInitialGuesses()
	{
		int popsize = 20;
		double maxx = 10;
		double minx = -10;
		
		List<Map<String,Object>> pop = new ArrayList<Map<String,Object>>();
		for (int k = 0; k < popsize; k++) {
			
         Map<String,Object> m = new HashMap<String,Object>();
			double rnum = Math.abs(maxx - minx)*Math.random() + minx;
			m.put("x", rnum);
			pop.add(m);
		}
		return pop;
	}
}
